package learning.spring.contacts.domain;

import javax.persistence.*;
import java.io.Serializable;

/**
 * Created with IntelliJ IDEA.
 * User: bibro
 * Date: 19.02.14
 * Time: 21:28
 * To change this template use File | Settings | File Templates.
 */

@Entity
@Table(name = "contact")
@NamedQueries(value = {
        @NamedQuery(name = "Contact.findAll",
                query = "select c from Contact c")
})
public class Contact implements Serializable {
    private Long Id;
    private String firstName;
    private String lastName;
    private String description;
    private int version;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID")
    public Long getId() {
        return Id;
    }

    public void setId(Long id) {
        Id = id;
    }

    @Column(name = "FIRST_NAME")
    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    @Column(name = "LAST_NAME")
    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    @Column(name = "DESCRIPTION")
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Version
    @Column(name = "VERSION")
    public int getVersion() {
        return this.version;
    }

    public void setVersion(int version) {
        this.version = version;
    }

    @Override
    public String toString() {
        return firstName + " - " + lastName + " - " + Id;
    }
}
